# -*- mode: Python -*-

include('../Tiltfile')

load('ext://restart_process', 'docker_build_with_restart')

# If you get push errors, you can change the default_registry.
# Create tilt_option.json with contents: {"default_registry": "gcr.io/my-personal-project"}
# (with your registry inserted). tilt_option.json is gitignore'd, unlike Tiltfile
default_registry(read_json('tilt_option.json', {})
                 .get('default_registry', 'gcr.io/windmill-test-containers/servantes'))

# We've specifically constructed this image to exercise the three most
# common Live Update codepaths:
# 1) A SYNC step
# 2) A RUN step that executes at build time (cp source.txt compiled.txt)
# 3) Process restart (via `docker_build_with_restart`)
docker_build_with_restart('rpdu', '.',
             entrypoint=['/src/main.sh'],
             live_update=[
                 sync('.', '/src'),
                 run('cp source.txt compiled.txt'),
             ])
k8s_yaml('rpdu.yaml')
k8s_resource('rpdu', port_forwards=['8100:8000', '8101:8001'])
